package org.tea.inventory.base.util;

import org.tea.inventory.base.response.BaseResponse;

import java.util.List;

public class ResponseUtil {
    public static final BaseResponse ok() {
        return new BaseResponse(0,"成功");
    }

    public static final BaseResponse ok(Object data) {
        return new BaseResponse(0,"成功",data);
    }

    public static final BaseResponse ok(String errmsg, Object data) {
        return new BaseResponse(0,errmsg,data);
    }

    public static final BaseResponse fail() {
        return new BaseResponse(-1,"错误");
    }

    public static final BaseResponse fail(String data) {
        return new BaseResponse(-1,"错误",data);
    }

    public static final BaseResponse fail(int errno, String errmsg) {
        return new BaseResponse(errno,errmsg);
    }
    public static final BaseResponse fail(int errno, String errmsg,List<String> errors) {
        return new BaseResponse(errno,errmsg,errors);
    }

    public static final BaseResponse fail401() {
        return fail(401, "请登录");
    }

    public static final BaseResponse fail402() {
        return fail(402, "参数不对");
    }

    public static final BaseResponse fail503() {
        return fail(503, "请登录");
    }

    public static final BaseResponse unlogin(){
        return fail401();
    }
    public static final BaseResponse userUnlogin(){
        return fail503();
    }

    public static final BaseResponse badArgument(){
        return fail402();
    }

    public static final BaseResponse fail403() {
        return fail(403, "参数值不对");
    }

    public static final BaseResponse badArgumentValue(){
        return fail403();
    }

    public static final BaseResponse fail501() {
        return fail(501, "业务不支持");
    }

    public static final BaseResponse unsupport(){
        return fail501();
    }

    public static final BaseResponse fail502() {
        return fail(502, "系统内部错误");
    }

    public static final BaseResponse serious(){
        return fail502();
    }

}

